#ifndef __CCUSTOM_CHECKBOX_CONTROL_H__
#define __CCUSTOM_CHECKBOX_CONTROL_H__

#include <gdiplus.h>
using namespace Gdiplus;

class CCustomCheckBox : public CButton
{
	DECLARE_DYNAMIC(CCustomCheckBox)

//*************************************************************************************************//Class Function
public:
	CCustomCheckBox(void);
	~CCustomCheckBox(void);

	//Common Setting
	BOOL GetChecked();
	void SetChecked(bool bChecked = true);
	BOOL EnableWindow(BOOL bEnable);
	void Initialize(HWND hPParentWnd, HWND hParentWnd, HDC hBgDC, HDC hDrawDC, int nParentx = 0, int nParenty = 0);

	//Image Setting
	void SetImage(UINT nCheckDis, UINT nCheckNormal, UINT nCheckHover, UINT nUncheckDis, UINT nUncheck, UINT nUncheckHover);
	void SetImage(LPCTSTR pszCheckDis, LPCTSTR pszCheckNormal, LPCTSTR pszCheckHover, 
		          LPCTSTR pszUncheckDis, LPCTSTR pszUncheckNormal, LPCTSTR pszUncheckHover);

	//String or Font Setting
	void SetWindowTextW(LPCTSTR lpszString);
	void SetFontSize(int nSize);
	void SetFontStyle(UINT nStyle);
	void SetFontColor(int nR, int nG, int nB);
	void SetFontFamily(CString strFontFamilyName);

	//UI Drawing
	void DrawUI();
	BOOL ShowWindow(int nCmdShow);

private:
	void SetState(int nState);
	void CreateFont();

//*************************************************************************************************//Class Parameters
public:
	enum{
		CBX_CHECKED_DISABLED = 0,	    // Column 0 : CB disabled in checked state
		CBX_CHECKED_NORMAL = 1,			    // Column 1 : checked state
		CBX_CHECKED_HOVERED = 2,	    // Column 2 : mouse hovered in checked state
		CBX_UNCHECKED_DISABLED = 3,     // Column 3 : CB disabled in unchecked state
		CBX_UNCHECKED_NORMAL = 4,			    // Column 4 : unchecked state
		CBX_UNCHECKED_HOVERED = 5,      // Column 5 : mouse hovered in unchecked state
	};

private:
	//commom Parameter
	int m_nState;
	bool m_bMouseDowned, m_bChecked;

	//String and Font Parameter
	CString m_strText;
	int m_nFontSize, m_nFontStyle;
	Gdiplus::Unit m_enFontUnit;
	Gdiplus::StringFormat* m_strTextFormat;
	Gdiplus::FontFamily* m_pFontFamily;
	Gdiplus::SolidBrush* m_pFontBrush;
	Gdiplus::Font* m_pFont;

	//UI Rect Parameter
	CRect m_rtRect, m_rtPRect, m_rtPPRect;

	//Image and Handle Parameter
	Image* m_pImg[6];
	HDC m_hBgDC, m_hDrawDC;
	HWND m_hPParentWnd, m_hParentWnd;

//*************************************************************************************************//Class Message
public:
	virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
	virtual void PreSubclassWindow();
	DECLARE_MESSAGE_MAP()
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg LRESULT OnMouseLeave(WPARAM wparam, LPARAM lparam);
	afx_msg LRESULT OnMouseHover(WPARAM wparam, LPARAM lparam);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
};
#endif
